<template>
  <div class="submit-handle-container">
    <el-form>
      <div v-if="isUdmNodes&&wfInstance.udmNodes&&curTN.modifyUdmNode!==0&&(wfInstance.status<1||(curTN.tnNodeID!=null&&curTN.userAccount==wfInstance.creatorAccount))" class="area-title"><i class="el-icon-plus" />定义流程环节</div>
      <div v-if="isUdmNodes&&wfInstance.udmNodes&&curTN.modifyUdmNode!==0&&(wfInstance.status<1||(curTN.tnNodeID!=null&&curTN.userAccount==wfInstance.creatorAccount))" class="el-table el-table--fit el-table--border" style="margin-bottom:20px;">
        <div class="el-table__body-wrapper">
          <table class="el-table__body" cellspacing="0" cellpadding="0" border="0">
            <tbody>
              <tr>
                <td class="tdlbl tdw17 tblbl-left">流程环节</td>
                <td class="tdcont " colspan="2">
                  环节处理人
                </td>
                <td class="tdcont " style="width:90px;text-align:center;">
                  <el-button icon="el-icon-plus" size="mini" style="border:0px;" @click.native="addUdmNode">添 加</el-button>
                </td>
              </tr>
              <tr v-for="(taskNode,index) in wfInstance.udmNodes" :key="index">
                <td class="tdlbl tdw17 tblbl-left">{{ taskNode.name }}</td>
                <td class="tdcont " colspan="2">{{ taskNode.userNames||taskNode.orgNames||taskNode.workgroupNames||taskNode.jobPositionNames }}</td>
                <td class="tdcont" style="width:90px;text-align:center;">
                  <el-link :underline="false" type="primary" icon="el-icon-edit" size="mini" style="font-size:16px!important;display:contents;" title="修改" @click.native="editUdmNode(taskNode)" />
                  &nbsp;&nbsp;
                  <el-link :underline="false" type="danger" :disabled="taskNode.startNode" icon="el-icon-close" size="mini" style="font-size:16px!important;display:contents;" title="删除" @click.native="delUdmNode(index)" />
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>

      <div v-if="isUdmNodes&&wfInstance.udmNodes&&curTN.modifyUdmNode!==0&&(wfInstance.status<1||(curTN.tnNodeID!=null&&curTN.userAccount==wfInstance.creatorAccount))" class="area-title"><i class="el-icon-check" />提交下一环节</div>
      <div v-if="wfJsonData.routes && wfJsonData.routes.length > 0" class="el-table el-table--fit el-table--border">
        <div class="el-table__body-wrapper">
          <table class="el-table__body" cellspacing="0" cellpadding="0" border="0">
            <tbody>
              <tr v-show="showOverPatnRow">
                <td class="tdlbl tdw17 " :class="wfInstance.udmNodes?'tblbl-left':''">提交路径</td>
                <td class="tdcont tdw83 selectPath" colspan="3">
                  <el-radio-group v-model="submitHandle.route.index" @change="initSubmitHandle">
                    <template v-for="(wfpath,index) in wfJsonData.routes">
                      <el-radio :key="wfpath.id" :label="index">
                        <span :title="wfpath.name">{{ wfpath.name }}</span>
                      </el-radio>
                    </template>
                  </el-radio-group>
                </td>
              </tr>
              <template v-for="(wfnode,index) in wfJsonData.routes[submitHandle.route.index].taskNodes">
                <tr v-if="wfnode.showNodeUsers!==0" :key="index">
                  <td class="tdlbl tdw17" :class="wfInstance.udmNodes?'tblbl-left':''">{{ wfnode.name }}</td>
                  <td class="tdcont tdw83" colspan="3">
                    <div v-if="wfnode.tmLmtType!=9&&wfnode.tmLmtCanEdit==1" class="tnLimit-container">
                      处理时限({{ wfnode.tmLmtType==1?'按工作日':'按自然日' }})<el-input v-model="wfnode.timeLimit" maxlength="2" @input="onTimeLimitInput(wfnode)" />天
                    </div>
                    <div v-if="(wfJsonData.routes[submitHandle.route.index].taskNodes.length===1 || wfJsonData.routes[submitHandle.route.index].mustNextTN.indexOf(wfnode.name) !== -1) && wfnode.users.length===1 && wfnode.users[0].type!=='asyncLoadingUsers'">{{ wfnode.users[0].name }}</div>
                    <div v-else style="width:100%;text-align:right;">
                      <div v-if="submitHandle.route[wfnode.name]" class="users-container">
                        <div v-for="user in submitHandle.route[wfnode.name].users" :key="user.id">{{ user.name }}<el-button v-if="wfnode.showNodeUsers!==2" type="text" icon="el-icon-close" size="mini" @click="removeSelectNodeUser(wfnode.id,wfnode.name,user)" /></div>
                      </div>
                      <el-button
                        v-if="!forceUpdate&&wfnode.showNodeUsers!==2"
                        v-model="wfNodeUser[wfnode.name]"
                        v-select-dialog="'wfNodeUser'"
                        :selected-order-by="wfnode.selectedOrderBy"
                        :onebyone="wfnode.oneByOne"
                        :multiple="wfnode.todoMode!==0 && wfnode.todoMode!=='0'"
                        :init-tree-data="wfnode.users"
                        :show-select-by-tabs="wfnode.showSelectByTabs"
                        size="mini"
                        style="border:0px;"
                        :name="wfnode.name"
                      >选择</el-button>
                    </div>
                  </td>
                </tr>
              </template>
              <tr v-if="curTN.tnIdeaLabelID&&(curTN.tnIdeaPosition!==1||submitMode==='dialog')">
                <td class="tdlbl tdw17" :class="wfInstance.udmNodes?'tblbl-left':''">
                  <span v-if="curTN.tnIdeaIsMust===1&&!wfInstance.udmNodes" class="required">*</span>
                  <span class="cur-idea-label">处理意见</span>
                  <span v-if="curTN.tnIdeaIsMust===1&&wfInstance.udmNodes" class="required">*</span>
                </td>
                <td class="tdcont tdw83" colspan="3">
                  <IdeaInputBox :submit-handle="submitHandle" :common-idea-list="commonIdeaList" />
                </td>
              </tr>
              <tr>
                <td class="tdlbl tdw17" :class="wfInstance.udmNodes?'tblbl-left':''">辅助办文</td>
                <td class="tdcont tdw83" colspan="3">
                  <el-row>
                    <el-col :span="8">
                      <el-checkbox v-if="msgTypeOptions===null" v-model="submitHandle.askSMS" :true-label="1" :false-label="0">短信通知</el-checkbox>
                      <el-checkbox v-else-if="msgTypeOptions.length>0" v-model="submitHandle.askSMS" :true-label="1" :false-label="0">待办通知</el-checkbox>
                      <el-checkbox v-model="submitHandle.keepConcern" :true-label="1" :false-label="0">保持关注</el-checkbox>
                    </el-col>
                    <el-col :span="16">
                      <SelectGroup v-if="(curTN.tnIdeaLabelID && curTN.tnIdeaLabelID!='')||noIdeaSubmitTemplate">
                        <el-select slot="select" v-model="submitTemplateIndex" name="submitTemplateList" :no-data-text="'暂无办理模板'" placeholder="---选择办理模板---" :clearable="true" @change="applySubmitTemplate">
                          <el-option
                            v-for="(item,index) in submitTemplateList"
                            :key="item.id"
                            :label="item.templateName"
                            :value="index"
                          />
                        </el-select>
                        <el-button slot="append" plain @click.native="saveSubmitTemplate">保存办理模板</el-button>
                      </SelectGroup>
                    </el-col>
                  </el-row>
                </td>
              </tr>
              <tr v-if="wfInstance.passenger.doNextNeedAttach===true">
                <td class="tdlbl tdw17" :class="wfInstance.udmNodes?'tblbl-left':''">
                  <span v-if="!wfInstance.udmNodes" class="required">*</span>
                  佐证材料
                  <span v-if="wfInstance.udmNodes" class="required">*</span>
                </td>
                <td class="tdcont tdw83" colspan="3">
                  <el-upload
                    ref="upload"
                    :on-change="handleUploadChange"
                    action=""
                    multiple="false"
                    :file-list="fileList"
                    :show-file-list="false"
                    :auto-upload="false"
                    :with-credentials="true"
                    :accept="accept"
                  >
                    <el-input v-model="doNextAttach.file.name" name="doNextFileName" :placeholder="'请选择佐证材料'">
                      <el-button slot="append" size="mini" icon="el-icon-upload2" />
                    </el-input>
                  </el-upload>
                </td>
              </tr>
              <tr v-if="shortcutButton">
                <td colspan="4" class="shortcut-button"><el-button :plain="btnType.plain" :type="btnType.type" @click="btnSubmitClick">&ensp;&ensp;&ensp;提&ensp;&ensp;交&ensp;&ensp;&ensp;</el-button></td>
              </tr>
            </tbody>
          </table>

        </div>
      </div>
    </el-form>

    <Basicform
      v-if="formTitle=='办理模板'"
      :title="formTitle"
      :win-width="850"
      :win-height="500"
      :append-to-body="true"
      :toolbar-btns="busiformBtns"
      :on-basic-form-before-open="onBasicFormBeforeOpen"
      :on-basic-form-submited="onBasicFormSubmited"
    >
      <template v-slot:default="slotProps">
        <busi-form :vo="slotProps?slotProps.vo:formVo" :can-edit="1" :module-info="submitTemplateModuleInfo" />
      </template>
    </Basicform>

    <WfTaskNode v-if="udmNode!=null" :task-node="udmNode" :idea-lables="wfJsonData.ideaLables" />
  </div>

</template>

<script>

import WfTaskNode from './WfTaskNode'

import { formatFileSize } from '@/global/utils/index'
import Cookies from 'js-cookie'

export default {
    name: 'SubmitHandle',
    components: {
        WfTaskNode
    },
    props: {
        curTN: { type: Object, default: function() { return {} } },
        wfInstance: { type: Object, default: function() { return {} } },
        wfJsonData: { type: Object, default: function() { return {} } },
        submitHandle: { type: Object, default: function() { return {} } },
        commonIdeaList: { type: Array, default: function() { return {} } },
        submitTemplateList: { type: Array, default: function() { return {} } },
        noIdeaSubmitTemplate: { type: Boolean, default: false },
        showOverPath: { type: Boolean, default: true },
        shortcutButton: { type: Boolean, default: false },
        btnType: { type: Object, default: function() { return { plain: true, type: 'primary' } } }
    },
    data() {
        return {
            forceUpdate: false,
            wfNodeUser: {},
            submitTemplateIndex: '',
            formTitle: '',
            formVo: null,
            submitTemplateModuleInfo: { 'formTemplate': 'dcontent/busiformurl?vwtype=W&url=/usersetting/submitTemplate/form.html', 'addNewUrl': 'usersetting/submitTemplate/addNew', 'insertUrl': 'usersetting/submitTemplate/insert', 'moduleCode': 'submitTemplate' },
            copy_$scope: {},
            udmNode: null,
            doNextAttach: { file: {}}, // 代办佐证材料
            showOverPatnRow: true,
            msgTypeOptions: null,
            isUdmNodes: false,
            submitMode: ''// 提交模式，dialog：窗口模式
        }
    },
    computed: {

    },
    watch: {
        wfJsonData: {
            handler: function(newValue, oldValue) {
                if (this.wfJsonData.ideaLables) {
                    if (this.wfInstance.udmNodes === null) {
                        this.wfInstance.udmNodes = []
                    }
                    this.$forceUpdate()
                }
                this.submitHandleValChange()
            },
            deep: true,
            immediate: true
        },
        wfInstance: {
            handler: function(newValue, oldValue) {
                if (this.wfInstance.udmNodes && this.wfInstance.udmNodes !== '[]' && typeof this.wfInstance.udmNodes === 'string') this.wfInstance.udmNodes = JSON.parse(this.wfInstance.udmNodes)
                if (this.wfInstance.udmNodes && (typeof this.wfInstance.udmNodes === 'object') && this.curTN.tnNodeID !== null) {
                    let curNode = null
                    const customRoutes = []
                    this.wfInstance.udmNodes.forEach((taskNode, index) => {
                        if (taskNode.name === this.curTN.tnNodeName) {
                            curNode = taskNode

                            if (curNode.canSendToNext !== 0 && this.wfInstance.udmNodes.length > (index + 1)) {
                                const nextNode = this.wfInstance.udmNodes[index + 1]
                                if (!nextNode.users) {
                                    nextNode.users = []
                                }
                                const nextRoute = {
                                    'evtMsg': '',
                                    'mustNextTN': '',
                                    'evtCplPercent': '0',
                                    'name': '送' + nextNode.name,
                                    'fullName': '送' + nextNode.name,
                                    'taskNodes': [JSON.parse(JSON.stringify(nextNode))],
                                    'type': '0'
                                }
                                customRoutes.push(nextRoute)
                            }
                        }
                    })

                    if (curNode == null) {
                        this.udmNode = null
                        this.wfInstance.udmNodes = null
                        return
                    }
                    if (curNode.canEndWflow !== 0) {
                        const endRoute = {
                            'evtMsg': '',
                            'mustNextTN': '',
                            'evtCplPercent': '0',
                            'name': '结束处理',
                            'fullName': '结束处理',
                            'taskNodes': [],
                            'type': '4'
                        }
                        customRoutes.push(endRoute)
                    }
                    if (curNode.canSendback !== 0 && this.wfInstance.udmNodes.length > 0 && this.curTN.tnNodeName !== this.wfInstance.udmNodes[0].name) {
                        const endRoute = {
                            'evtMsg': '',
                            'mustNextTN': '',
                            'evtCplPercent': '0',
                            'name': '退回',
                            'fullName': '退回',
                            'taskNodes': [JSON.parse(JSON.stringify(this.wfInstance.udmNodes[0]))],
                            'type': '3'
                        }
                        customRoutes.push(endRoute)
                    }
                    this.wfInstance.udmNodes.forEach((taskNode, index) => {
                        if (taskNode.name === this.curTN.tnNodeName) {
                            curNode = taskNode

                            if (curNode.canSendToOther !== 0 && this.wfInstance.passenger.allUsers) {
                                const sendToOtherNode = JSON.parse(JSON.stringify(taskNode))
                                sendToOtherNode.users = JSON.parse(this.wfInstance.passenger.allUsers) // 单位全体人员
                                const sendToOtherRoute = {
                                    'evtMsg': '',
                                    'mustNextTN': '',
                                    'evtCplPercent': '0',
                                    'name': this.isUdmNodes ? '增加处理人' : '转派',
                                    'fullName': this.isUdmNodes ? '增加处理人' : '转派',
                                    'taskNodes': [sendToOtherNode],
                                    'type': '4'
                                }
                                customRoutes.push(sendToOtherRoute)
                            }
                        }
                    })
                    this.wfJsonData.routes = customRoutes

                    this.initSubmitHandle()
                }
                this.$forceUpdate()
                this.submitHandleValChange()
            },
            immediate: true,
            deep: true
        },
        submitHandle: {
            handler() {
                this.submitHandleValChange()
            },
            deep: true,
            immediate: true
        }
    },
    created() {
        this.$bus.on('initSubmitHandle', this.initSubmitHandle)
    },
    beforeDestroy() {
        this.$bus.off('initSubmitHandle', this.initSubmitHandle)
    },
    updated() {
        if (window.submitMode === 'dialog' || this.submitMode === 'dialog') {
            this.$nextTick(() => {
                this.$bus.emit('submitHanddleUpdate')
            })
        }
    },
    mounted() {
        this.submitMode = this.$vnode.context.submitMode
        this.isUdmNodes = this.wfInstance.module.indexOf('udmjysp_') === 0
        this.msgTypeOptions = this.wfInstance.passenger.msgTypeOptions || null

        this.initSubmitHandle()
    },
    methods: {
        submitHandleValChange() {
            this.$bus.emit('submitHandleValChange', this)
        },
        initSubmitHandle() {
            if (this.wfJsonData.routes && this.wfJsonData.routes.length > 0) {
                if (this.wfJsonData.routes.length === 1 && this.wfJsonData.routes[0].name.indexOf('结束') > -1) {
                    if (!this.showOverPath) {
                        this.showOverPatnRow = false
                    } else {
                        this.showOverPatnRow = true
                    }
                }

                this.submitHandle.route = { index: this.submitHandle.route.index }
                this.wfJsonData.routes[this.submitHandle.route.index].taskNodes.forEach(taskNode => {
                    this.submitHandle.route[taskNode.name] = { users: [] }
                    if (taskNode.users === null) taskNode.users = []

                    delete this.wfNodeUser[taskNode.name]
                    if (taskNode.autoCheckedAll === '1' && (taskNode.type === '3' || taskNode.todoMode === '0' || taskNode.todoMode === '1' || taskNode.todoMode === '3' || taskNode.todoMode === '4')) {
                        let userIds = ''
                        let deptIds = ''
                        const selectedNodes = []

                        if (taskNode.todoMode === '0') {
                            // 单人，并且设置自动全选处理人等于1
                            if (taskNode.users.length === 1) {
                                const orgFullId = taskNode.users[0].orgFullId || 'corpid-deptid'

                                if (deptIds.indexOf(orgFullId.split('-')[1]) === -1 || taskNode.oneByOne !== '1') {
                                    userIds += taskNode.users[0].id + ','
                                    selectedNodes.push(taskNode.users[0])
                                    deptIds += orgFullId.split('-')[1] + ','
                                }
                            }
                        } else {
                            // 阅文环节、多人并行、多人串行、多人竞争，并且设置自动全选处理人等于1
                            taskNode.users.forEach(user => {
                                if (user.personId) {
                                    const orgFullId = user.orgFullId || 'corpid-deptid'

                                    if (deptIds.indexOf(orgFullId.split('-')[1]) === -1 || taskNode.oneByOne !== '1') {
                                        userIds += user.id + ','
                                        selectedNodes.push(user)
                                        deptIds += orgFullId.split('-')[1] + ','
                                    }
                                }
                            })
                        }

                        this.$set(this.wfNodeUser, taskNode.name, userIds)

                        this.submitHandle.route[taskNode.name].users = selectedNodes
                    } else {
                        const wfusers = Cookies.get('route-wfuser-' + this.wfInstance.id + '-' + taskNode.id)
                        if (wfusers !== undefined && wfusers !== null) {
                            const selectedNodes = []
                            taskNode.users.forEach(user => {
                                if (wfusers.indexOf(user.id) !== -1) {
                                    selectedNodes.push(user)
                                }
                            })
                            this.$set(this.wfNodeUser, taskNode.name, wfusers)

                            this.submitHandle.route[taskNode.name].users = selectedNodes
                        }
                    }

                    if (taskNode.type === '1' && taskNode.todoMode === '3') {
                        taskNode.selectedOrderBy = 'selectedIndex'
                    } else {
                        taskNode.selectedOrderBy = 'orgOrderNo'
                    }

                    if ((this.wfJsonData.routes[this.submitHandle.route.index].taskNodes.length === 1 || this.wfJsonData.routes[this.submitHandle.route.index].mustNextTN.indexOf(taskNode.name) !== -1)) {
                        if (taskNode.users.length === 1 && taskNode.users[0].type !== 'asyncLoadingUsers') {
                            this.submitHandle.route[taskNode.name].users = taskNode.users
                        }
                    }
                })

                this.forceUpdate = true
                this.$nextTick(() => {
                    this.forceUpdate = false
                })
                this.$forceUpdate()
            } else if (this.wfInstance.udmNodes && this.wfInstance.udmNodes !== '[]') {
                this.wfInstance.udmNodes = JSON.parse(this.wfInstance.udmNodes)
                this.$forceUpdate()
            } else if (this.wfInstance.passenger.udmjysp) {
                const tnUsers = [{ 'id': this.curTN.staffID }]
                const udmNode = { todoMode: 0, canEdit: 1, status: 1, name: this.curTN.tnNodeName, userNames: this.curTN.userName, users: tnUsers, id: this.curTN.tnNodeID, uuid: this.curTN.tnNodeID, startNode: true, ideaLable: '' }
                this.wfInstance.udmNodes = [udmNode]
            }
        },
        onTimeLimitInput(wfnode) {
            if (!isNaN(parseInt(wfnode.timeLimit))) {
                wfnode.timeLimit = parseInt(wfnode.timeLimit)
            } else {
                wfnode.timeLimit = ''
            }
        },
        onSelectWfNodeUserCompleted(selectedNodes, attrs) {
            let userIds = ''
            selectedNodes.forEach(user => {
                userIds += user.id + ','
            })
            this.$set(this.wfNodeUser, attrs.name, userIds)
            if (!this.submitHandle.route[attrs.name]) this.submitHandle.route[attrs.name] = {}
            this.submitHandle.route[attrs.name].users = selectedNodes
            this.$nextTick(() => {
                this.submitHandleValChange()
            })
        },
        removeSelectNodeUser(wfNodeId, wfNodeName, user) {
            const index = this.submitHandle.route[wfNodeName].users.indexOf(user)
            this.submitHandle.route[wfNodeName].users.splice(index, 1)

            let userIds = ''
            this.submitHandle.route[wfNodeName].users.forEach(user => {
                userIds += user.id + ','
            })
            this.$set(this.wfNodeUser, wfNodeName, userIds)
            Cookies.set('route-wfuser-' + this.wfInstance.id + '-' + wfNodeId, '', { expires: 0 })
        },
        onBasicFormBeforeOpen($scope, vo, defer) {
            console.log($scope.moduleInfo.moduleCode + ' form before open')

            $scope.$set(vo, 'ownerStaffId', this.curTN.staffID)
            if (this.curTN.tnIdeaLabelID) {
                $scope.$set(vo, 'submitIdea', this.submitHandle.curUserIdea)
            }

            const submitJsondata = JSON.parse(JSON.stringify(this.submitHandle))
            submitJsondata.submitRoute = JSON.parse(JSON.stringify(this.wfJsonData.routes[this.submitHandle.route.index]))
            delete submitJsondata.submitRoute.taskNodes
            delete submitJsondata.needCheckOuterDeputy
            $scope.$set(vo, 'submitJsondata', submitJsondata)
            $scope.$set(vo, 'submitRoute', this.wfJsonData.routes[this.submitHandle.route.index].name)
            $scope.$set(vo, 'templateName', this.wfJsonData.routes[this.submitHandle.route.index].name)

            this.formVo = vo
            defer.resolve(true)
        },
        onBasicFormSubmited($scope, vo) {
            console.log($scope.moduleInfo.moduleCode + ' form submited')
            this.formTitle = ''
            this.formVo = null

            const template_copy = $scope.vo
            delete template_copy.passenger
            template_copy.submitJsondata = JSON.stringify(template_copy.submitJsondata)
            let updated = false
            for (var i = 0; i < this.submitTemplateList.length; i++) {
                if (this.submitTemplateList[i].templateName === template_copy.templateName) {
                    this.submitTemplateList[i] = template_copy
                    updated = true
                    break
                }
            }
            if (!updated) {
                this.submitTemplateList.unshift(template_copy)
            }
        },
        saveSubmitTemplate() {
            if (this.curTN.tnIdeaLabelID && this.curTN.tnIdeaIsMust === 1) {
                if (this.submitHandle.curUserIdea === null || this.submitHandle.curUserIdea.trim() === '') {
                    this.$alert('请填写处理意见。', '操作提示', { type: 'warning' })
                    return
                }
            }

            const res = this.$wfEngine.checkSubmitHandle(this, 'Submit')
            if (res.code !== 'success') {
                this.$alert(res.message, '操作提示', { type: 'warning' })
                return
            }
            this.formTitle = '办理模板'
            this.$options.components['BusiForm'] = this.$wfEngine.loadBusiform(this, this.submitTemplateModuleInfo.formTemplate, 'W')
            this.$nextTick(() => {
                this.$bus.emit('openBusiform', this.submitTemplateModuleInfo, null, 1)
            })
        },
        applySubmitTemplate(val) {
            if (val !== '') {
                this.$wfEngine.applySubmitTemplate(this, JSON.parse(this.submitTemplateList[this.submitTemplateIndex].submitJsondata))
            }
        },
        addUdmNode() {
            this.udmNode = { todoMode: 0, canEdit: 1, status: 0, ideaLable: '' }
        },
        editUdmNode(udmNode) {
            this.udmNode = JSON.parse(JSON.stringify(udmNode))
            this.$forceUpdate()
        },
        delUdmNode(index) {
            this.wfInstance.udmNodes.splice(index, 1)
            this.$forceUpdate()
        },
        handleUploadChange(file, fileList) {
            const accept = '.doc,.docx,.pdf'
            const extName = file.name.substring(file.name.lastIndexOf('.')).toLowerCase()

            if (accept.indexOf(extName) === -1) {
                this.$alert('您上传的文件格式有误，仅支持' + accept.replace(/,/g, '、') + '格式的文件！', '提示', { confirmButtonText: '确定', type: 'warning' })
                this.fileList = []
                return
            }

            if (this.doNextAttach.name !== undefined) {
                const attachments = this.$vnode.context.attachments
                for (var i = 0; i < attachments.length; i++) {
                    if (attachments[i].uploadBy.indexOf(this.curTN.tnID) !== -1 && attachments[i].fileType === 'DONEXT' && attachments[i].uploadTime === '待上传') {
                        attachments.splice(i--, 1)
                    }
                }
            }
            const attach = {}
            attach.fileName = file.name
            attach.fileSize = formatFileSize(file.size)
            attach.fileType = 'DONEXT'
            attach.uploadBy = this.curTN.userName + '_' + this.curTN.tnID
            attach.uploadTime = '待上传'
            attach.file = file
            attach.checked = false
            file.progress = 0

            this.doNextAttach = attach
            this.$vnode.context.doNextAttach = attach
        },
        btnSubmitClick() {
            const $scope = this.$vnode.context
            $scope.btnSubmitClick()
        }
    }
}
</script>

<style scoped lang="scss">
.area-title{
  margin-bottom: 10px;
  font-weight: 600;
  .el-icon-plus{
    margin-right: 5px;
    font-size: 14px;
    font-weight:600;
  }
  .el-icon-check{
    margin-right: 5px;
    font-size: 14px;
    font-weight:600;
  }
}
.submit-handle-container{
    margin-top:20px;

    .tnLimit-container{
        border-bottom: 1px solid #EBEEF5;
        margin-left: -4px;
        margin-right: -4px;
        padding-left: 4px;
        padding-bottom: 5px;
        margin-bottom: 5px;
        .el-input{
            width: 40px;

            /deep/ .el-input__inner{
                border-top: 0px;
                border-left: 0px;
                border-right: 0px;
                border-radius:0px;
                text-align: center;
            }
        }
    }
    .users-container{
        margin-right: 45px;

        .el-button{
            padding-left: 6px;
            padding-right: 6px;
        }

        div{
            float: left;
        }
        div:after {
            content: "、";
        }
        div:last-child:after {
            content: "";
        }
    }
    .selectPath{
      /deep/ .el-radio{
        width:130px;
        line-height: 25px;
        overflow: hidden;
        overflow:hidden;
        text-overflow:ellipsis;
        white-space:nowrap;
      }
    }

    /deep/ .el-upload--text{
        width:100%;
    }
    /deep/ .el-upload .el-input-group .el-input__inner{
       display:inline-block;
       vertical-align:baseline;
    }

    .shortcut-button{
      text-align: right;

      /deep/ .el-button{
        font-weight: 600;
      }
    }
}
</style>
